using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;

using System.Reflection;
using Gizmox.WebGUI.Common.Resources;
using Gizmox.WebGUI.Forms;

using System.Text;
using System.IO;
using TVC.Layout;

namespace TVC.Modules.Com
{
    /// <summary>
    /// Summary description for CustomWindowPanelControl.
    /// </summary>

    [Serializable()]
    public class POD : ModuleParent, IHostedApplication
    {
        private TabControl tabControl1;
        private TabPage tbList;
        private TabPage tbDetail;
        private Label lblDescription;
        private TextBox txtUSER_NAME;
        private TextBox txtUSER_ID;
        private Label lbUserName;
        private Label lblDbDefault;
        private Label lblLanguage;
        private TextBox txtLANGUAGE;
        private TextBox txtDB_DEFAULT;
        private DataGridView dgvList;
        private BindingSource bsPOD;
        private IContainer components;
        private TextBox txtPASS;
        private LinkLabel lklRole;
        private Button btnReset;
        private string strAction;
        private MenuItem menuItem1;
        private CustomControl.MultiColumnCombo mcbROLE_ID;
        private ContextMenu ctmGrid;
        private MenuItem menuItem2;
        private MenuItem mnuSaveLayout;
        private MenuItem mnuResetLayout;
        private MenuItem mnuShowFilter;
        private CustomControl.MultiColCombo test1;
        private BindingSource bsCombo;
        GridLayout layout = null;
        public POD()
        {
            // This call is required by the WebGUI Form Designer.
            InitializeComponent();
            _strType = "POD";
            _dgvList = dgvList;
            _tabControl = tabControl1;
        }



        protected override void LoadLanguage(string language)
        {
            foreach (Control x in tbDetail.Controls)
            {
                if (x is Label)
                {
                    clsConfigurarion.GetLabel(this.ToString(), x, language);
                }
                if (x is GroupBox || x is ExpandableGroupBox || x is Panel)
                {
                    clsConfigurarion.GetLabel(this.ToString(), x, language);
                    foreach (Control y in x.Controls)
                    {
                        if (y is Label)
                            clsConfigurarion.GetLabel(this.ToString(), y, language);
                    }
                }
            }

            if (this.Parent is HeaderedPanel)
            {
                HeaderedPanel pln = this.Parent as HeaderedPanel;
                _title = clsConfigurarion.GetLabel(this.ToString(), "", null, language);
            }
        }


        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code
        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.tabControl1 = new Gizmox.WebGUI.Forms.TabControl();
            this.tbList = new Gizmox.WebGUI.Forms.TabPage();
            this.dgvList = new Gizmox.WebGUI.Forms.DataGridView();
            this.ctmGrid = new Gizmox.WebGUI.Forms.ContextMenu();
            this.menuItem2 = new Gizmox.WebGUI.Forms.MenuItem();
            this.mnuSaveLayout = new Gizmox.WebGUI.Forms.MenuItem();
            this.mnuResetLayout = new Gizmox.WebGUI.Forms.MenuItem();
            this.mnuShowFilter = new Gizmox.WebGUI.Forms.MenuItem();
            this.bsPOD = new Gizmox.WebGUI.Forms.BindingSource(this.components);
            this.tbDetail = new Gizmox.WebGUI.Forms.TabPage();
            this.test1 = new TVC.Modules.CustomControl.MultiColCombo();
            this.mcbROLE_ID = new TVC.Modules.CustomControl.MultiColumnCombo();
            this.btnReset = new Gizmox.WebGUI.Forms.Button();
            this.lklRole = new Gizmox.WebGUI.Forms.LinkLabel();
            this.txtPASS = new Gizmox.WebGUI.Forms.TextBox();
            this.lblDbDefault = new Gizmox.WebGUI.Forms.Label();
            this.lblLanguage = new Gizmox.WebGUI.Forms.Label();
            this.lblDescription = new Gizmox.WebGUI.Forms.Label();
            this.txtLANGUAGE = new Gizmox.WebGUI.Forms.TextBox();
            this.txtUSER_NAME = new Gizmox.WebGUI.Forms.TextBox();
            this.txtUSER_ID = new Gizmox.WebGUI.Forms.TextBox();
            this.txtDB_DEFAULT = new Gizmox.WebGUI.Forms.TextBox();
            this.lbUserName = new Gizmox.WebGUI.Forms.Label();
            this.menuItem1 = new Gizmox.WebGUI.Forms.MenuItem();
            this.bsCombo = new Gizmox.WebGUI.Forms.BindingSource(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.tabControl1)).BeginInit();
            this.tabControl1.SuspendLayout();
            this.tbList.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dgvList)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.bsPOD)).BeginInit();
            this.tbDetail.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.bsCombo)).BeginInit();
            this.SuspendLayout();
            // 
            // errProvider
            // 
            this.errProvider.BlinkStyle = Gizmox.WebGUI.Forms.ErrorBlinkStyle.BlinkIfDifferentError;
            // 
            // warnProvider
            // 
            this.warnProvider.BlinkStyle = Gizmox.WebGUI.Forms.ErrorBlinkStyle.BlinkIfDifferentError;
            // 
            // tabControl1
            // 
            this.tabControl1.Alignment = Gizmox.WebGUI.Forms.TabAlignment.Bottom;
            this.tabControl1.Appearance = Gizmox.WebGUI.Forms.TabAppearance.Workspace;
            this.tabControl1.Controls.Add(this.tbList);
            this.tabControl1.Controls.Add(this.tbDetail);
            this.tabControl1.Dock = Gizmox.WebGUI.Forms.DockStyle.Fill;
            this.tabControl1.Location = new System.Drawing.Point(3, 3);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(601, 442);
            this.tabControl1.TabIndex = 0;
            // 
            // tbList
            // 
            this.tbList.Controls.Add(this.dgvList);
            this.tbList.Dock = Gizmox.WebGUI.Forms.DockStyle.Fill;
            this.tbList.Location = new System.Drawing.Point(4, 22);
            this.tbList.Name = "tbList";
            this.tbList.Size = new System.Drawing.Size(593, 416);
            this.tbList.TabIndex = 0;
            this.tbList.Text = "List";
            // 
            // dgvList
            // 
            this.dgvList.AllowUserToAddRows = false;
            this.dgvList.AllowUserToDeleteRows = false;
            this.dgvList.AutoGenerateColumns = false;
            this.dgvList.BackgroundColor = System.Drawing.Color.White;
            this.dgvList.ColumnHeadersHeightSizeMode = Gizmox.WebGUI.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dgvList.ContextMenu = this.ctmGrid;
            this.dgvList.DataSource = this.bsPOD;
            this.dgvList.Dock = Gizmox.WebGUI.Forms.DockStyle.Fill;
            this.dgvList.ItemsPerPage = 50;
            this.dgvList.Location = new System.Drawing.Point(0, 0);
            this.dgvList.Name = "dgvList";
            this.dgvList.RowHeadersWidth = 25;
            this.dgvList.RowTemplate.DefaultCellStyle.FormatProvider = new System.Globalization.CultureInfo("en-US");
            this.dgvList.ShowFilterRow = true;
            this.dgvList.Size = new System.Drawing.Size(593, 416);
            this.dgvList.TabIndex = 0;
            // 
            // ctmGrid
            // 
            this.ctmGrid.MenuItems.AddRange(new Gizmox.WebGUI.Forms.MenuItem[] {
            this.menuItem2,
            this.mnuShowFilter});
            // 
            // menuItem2
            // 
            this.menuItem2.Index = 0;
            this.menuItem2.MenuItems.AddRange(new Gizmox.WebGUI.Forms.MenuItem[] {
            this.mnuSaveLayout,
            this.mnuResetLayout});
            this.menuItem2.Text = "Layout";
            // 
            // mnuSaveLayout
            // 
            this.mnuSaveLayout.Index = 0;
            this.mnuSaveLayout.Tag = "SAVE";
            this.mnuSaveLayout.Text = "Save Layout";
            // 
            // mnuResetLayout
            // 
            this.mnuResetLayout.Index = 1;
            this.mnuResetLayout.Tag = "RESET";
            this.mnuResetLayout.Text = "Reset Layout";
            // 
            // mnuShowFilter
            // 
            this.mnuShowFilter.Index = 1;
            this.mnuShowFilter.Tag = "FILTER";
            this.mnuShowFilter.Text = "Filter Records";
            // 
            // bsPOD
            // 
            this.bsPOD.DataSource = typeof(DTO.PODInfo);
            // 
            // tbDetail
            // 
            this.tbDetail.Controls.Add(this.test1);
            this.tbDetail.Controls.Add(this.mcbROLE_ID);
            this.tbDetail.Controls.Add(this.btnReset);
            this.tbDetail.Controls.Add(this.lklRole);
            this.tbDetail.Controls.Add(this.txtPASS);
            this.tbDetail.Controls.Add(this.lblDbDefault);
            this.tbDetail.Controls.Add(this.lblLanguage);
            this.tbDetail.Controls.Add(this.lblDescription);
            this.tbDetail.Controls.Add(this.txtLANGUAGE);
            this.tbDetail.Controls.Add(this.txtUSER_NAME);
            this.tbDetail.Controls.Add(this.txtUSER_ID);
            this.tbDetail.Controls.Add(this.txtDB_DEFAULT);
            this.tbDetail.Controls.Add(this.lbUserName);
            this.tbDetail.Dock = Gizmox.WebGUI.Forms.DockStyle.Fill;
            this.tbDetail.Location = new System.Drawing.Point(0, 0);
            this.tbDetail.Name = "tbDetail";
            this.tbDetail.Size = new System.Drawing.Size(593, 416);
            this.tbDetail.TabIndex = 1;
            this.tbDetail.Text = "Detail";
            // 
            // test1
            // 
            this.test1.AutoValidate = Gizmox.WebGUI.Forms.AutoValidate.EnableAllowFocusChange;
            this.test1.BackColor = System.Drawing.Color.Transparent;
            this.test1.Binding = null;
            this.test1.DisplayRows = 25;
            this.test1.Filter = true;
            this.test1.FilterColumn = new int[] {
        0,
        0,
        0};
            this.test1.FilterValue = new string[] {
        null,
        null,
        null};
            this.test1.KeyPressChk = false;
            this.test1.Location = new System.Drawing.Point(239, 129);
            this.test1.MaxDropDownItems = 8;
            this.test1.Name = "test1";
            this.test1.RowData = new string[] {
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null};
            this.test1.Size = new System.Drawing.Size(122, 21);
            this.test1.TabIndex = 8;
            this.test1.Text = "MCCB";
            this.test1.Visible = false;
            // 
            // mcbROLE_ID
            // 
            this.mcbROLE_ID.AllowDrag = false;
            this.mcbROLE_ID.AutoScroll = false;
            this.mcbROLE_ID.AutoValidate = Gizmox.WebGUI.Forms.AutoValidate.Disable;
            this.mcbROLE_ID.Binding = null;
            this.mcbROLE_ID.DisplayField = null;
            this.mcbROLE_ID.DisplayRows = 0;
            this.mcbROLE_ID.Filter = false;
            this.mcbROLE_ID.KeyPressChk = false;
            this.mcbROLE_ID.Layout = null;
            this.mcbROLE_ID.Location = new System.Drawing.Point(115, 71);
            this.mcbROLE_ID.Lookup = null;
            this.mcbROLE_ID.MainForm = null;
            this.mcbROLE_ID.Name = "mcbROLE_ID";
            this.mcbROLE_ID.RowData = null;
            this.mcbROLE_ID.RowDatas = null;
            this.mcbROLE_ID.Size = new System.Drawing.Size(123, 20);
            this.mcbROLE_ID.TabIndex = 1;
            this.mcbROLE_ID.Value = "";
            this.mcbROLE_ID.ValueField = null;
            // 
            // btnReset
            // 
            this.btnReset.Location = new System.Drawing.Point(257, 71);
            this.btnReset.Name = "btnReset";
            this.btnReset.Size = new System.Drawing.Size(125, 23);
            this.btnReset.TabIndex = 7;
            this.btnReset.Text = "Reset Password";
            this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
            // 
            // lklRole
            // 
            this.lklRole.AutoSize = true;
            this.lklRole.ClientMode = false;
            this.lklRole.LinkColor = System.Drawing.Color.Blue;
            this.lklRole.Location = new System.Drawing.Point(20, 74);
            this.lklRole.Name = "lklRole";
            this.lklRole.Size = new System.Drawing.Size(28, 13);
            this.lklRole.TabIndex = 6;
            this.lklRole.TabStop = true;
            this.lklRole.Text = "Role";
            this.lklRole.LinkClicked += new Gizmox.WebGUI.Forms.LinkLabelLinkClickedEventHandler(this.lklROLE_ID_LinkClicked);
            // 
            // txtPASS
            // 
            this.txtPASS.AllowDrag = false;
            this.txtPASS.Location = new System.Drawing.Point(221, 13);
            this.txtPASS.Name = "txtPASS";
            this.txtPASS.Size = new System.Drawing.Size(39, 20);
            this.txtPASS.TabIndex = 3;
            this.txtPASS.Visible = false;
            // 
            // lblDbDefault
            // 
            this.lblDbDefault.AutoSize = true;
            this.lblDbDefault.Location = new System.Drawing.Point(20, 129);
            this.lblDbDefault.Name = "lblDbDefault";
            this.lblDbDefault.Size = new System.Drawing.Size(91, 13);
            this.lblDbDefault.TabIndex = 0;
            this.lblDbDefault.Text = "Database Default";
            this.lblDbDefault.Visible = false;
            // 
            // lblLanguage
            // 
            this.lblLanguage.AutoSize = true;
            this.lblLanguage.Location = new System.Drawing.Point(20, 103);
            this.lblLanguage.Name = "lblLanguage";
            this.lblLanguage.Size = new System.Drawing.Size(54, 13);
            this.lblLanguage.TabIndex = 0;
            this.lblLanguage.Text = "Language";
            this.lblLanguage.Visible = false;
            // 
            // lblDescription
            // 
            this.lblDescription.AutoSize = true;
            this.lblDescription.Location = new System.Drawing.Point(20, 45);
            this.lblDescription.Name = "lblDescription";
            this.lblDescription.Size = new System.Drawing.Size(60, 13);
            this.lblDescription.TabIndex = 0;
            this.lblDescription.Text = "Description";
            // 
            // txtLANGUAGE
            // 
            this.txtLANGUAGE.AllowDrag = false;
            this.txtLANGUAGE.Location = new System.Drawing.Point(115, 100);
            this.txtLANGUAGE.MaxLength = 15;
            this.txtLANGUAGE.Name = "txtLANGUAGE";
            this.txtLANGUAGE.Size = new System.Drawing.Size(100, 20);
            this.txtLANGUAGE.TabIndex = 4;
            this.txtLANGUAGE.Visible = false;
            // 
            // txtUSER_NAME
            // 
            this.txtUSER_NAME.AllowDrag = false;
            this.txtUSER_NAME.Location = new System.Drawing.Point(115, 42);
            this.txtUSER_NAME.Name = "txtUSER_NAME";
            this.txtUSER_NAME.Size = new System.Drawing.Size(436, 20);
            this.txtUSER_NAME.TabIndex = 1;
            // 
            // txtUSER_ID
            // 
            this.txtUSER_ID.AllowDrag = false;
            this.txtUSER_ID.Location = new System.Drawing.Point(115, 13);
            this.txtUSER_ID.MaxLength = 15;
            this.txtUSER_ID.Name = "txtUSER_ID";
            this.txtUSER_ID.Size = new System.Drawing.Size(100, 20);
            this.txtUSER_ID.TabIndex = 0;
            this.txtUSER_ID.LostFocus += new System.EventHandler(this.txtUSER_ID_LostFocus);
            // 
            // txtDB_DEFAULT
            // 
            this.txtDB_DEFAULT.AllowDrag = false;
            this.txtDB_DEFAULT.Location = new System.Drawing.Point(115, 126);
            this.txtDB_DEFAULT.Name = "txtDB_DEFAULT";
            this.txtDB_DEFAULT.Size = new System.Drawing.Size(100, 20);
            this.txtDB_DEFAULT.TabIndex = 3;
            this.txtDB_DEFAULT.Visible = false;
            // 
            // lbUserName
            // 
            this.lbUserName.AutoSize = true;
            this.lbUserName.Location = new System.Drawing.Point(20, 16);
            this.lbUserName.Name = "lbUserName";
            this.lbUserName.Size = new System.Drawing.Size(43, 13);
            this.lbUserName.TabIndex = 0;
            this.lbUserName.Text = "User ID";
            // 
            // menuItem1
            // 
            this.menuItem1.Index = -1;
            // 
            // POD
            // 
            this.Controls.Add(this.tabControl1);
            this.DockPadding.All = 3;
            this.Location = new System.Drawing.Point(0, -10);
            this.Padding = new Gizmox.WebGUI.Forms.Padding(3);
            this.Size = new System.Drawing.Size(607, 448);
            this.Load += new System.EventHandler(this.POD_Load);
            ((System.ComponentModel.ISupportInitialize)(this.tabControl1)).EndInit();
            this.tabControl1.ResumeLayout(false);
            this.tbList.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.dgvList)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.bsPOD)).EndInit();
            this.tbDetail.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.bsCombo)).EndInit();
            this.ResumeLayout(false);

        }
        #endregion
        int idAllowEditLanguage = 1;
        int id = 22;
        int idAddNew = 23;
        int idEdit = 24;
        int idDelete = 25;
        int idTransferIn = 26;
        int idTransferOut = 27;
        int idPrint = 28;
        int idResetPassword = 29;
        int idToExcel = 264;




        #region IHostedApplication Members

        public void InitializeApplication()
        {
        }

        public void SetObject(object obj)
        {


        }
        public HostedToolBarElement[] GetToolBarElements()
        {
            ArrayList objElements = new ArrayList();
            if (IsPermis(idAddNew))
                objElements.Add(new HostedToolBarButton("Add New", new IconResourceHandle("Add.png"), "C"));
            if (IsPermis(idEdit))
                objElements.Add(new HostedToolBarButton("Edit", new IconResourceHandle("Edit.png"), "A"));
            if (IsPermis(idAddNew) || IsPermis(idEdit))
                objElements.Add(new HostedToolBarButton("Save", new IconResourceHandle("Save.png"), "S"));
            if (IsPermis(idAddNew))
                objElements.Add(new HostedToolBarButton("Copy", new IconResourceHandle("Copy.png"), "O"));
            objElements.Add(new HostedToolBarButton("Skip", "Skip", new IconResourceHandle("Reject.png"), "K"));
            if (IsPermis(idDelete))
                objElements.Add(new HostedToolBarButton("Delete", new IconResourceHandle("Delete.png"), "X"));
            
            
            objElements.Add(new HostedToolBarSeperator());
            if (IsPermis(idTransferIn))
                objElements.Add(new HostedToolBarButton("Import", new IconResourceHandle("Down.png"), "TI"));  
            if (IsPermis(idPrint)) objElements.Add(new HostedToolBarButton("To XML", "To XML", new IconResourceHandle("Up.png"), "TO"));
            if (IsPermis(idToExcel)) objElements.Add(new HostedToolBarButton("To Excel", "To Excel", new IconResourceHandle("Excel.png"), "EXCEL"));

            objElements.Add(new HostedToolBarSeperator());
            objElements.Add(new HostedToolBarButton("Refresh", new IconResourceHandle("Refresh.png"), "R"));

            return (HostedToolBarElement[])objElements.ToArray(typeof(HostedToolBarElement));
        }
        protected override void InitPermisControl()
        {
            _permisControl.Add(new MyPermisControl(idResetPassword, btnReset));
        }
        public void OnToolBarButtonClick(HostedToolBarButton objButton, EventArgs objEvent)
        {
            Cancel = false;
            try
            {
                sErr = "";
                strAction = (string)objButton.Tag;

                BUS.PODControl ctr = new BUS.PODControl();
                switch (strAction)
                {
                    case "K":
                        skip();
                        break;
                    case "C":
                        AddNew(txtUSER_ID);
                        break;
                    case "A":
                        editRecord(txtUSER_ID);
                        break;
                    case "S":
                        saveRecord(txtUSER_ID);
                        break;
                    case "O":
                        copy(txtUSER_ID);
                        break;
                    case "X":
                        delete(txtUSER_ID);

                        break;
                  
                    case "TI": //trans in
                        importData();
                        break;
                    case "TO": //Tran out
                        export2Xml();
                        break;
                    case "EXCEL": //Tran out
                        export2Excel();
                        break;

                    case "R":
                        reloadList();
                        break;
                    case "P":
                        if (dgvList.CurrentCell != null)
                        {
                            DTO.PODInfo info = new DTO.PODInfo((DataRowView)dgvList.CurrentRow.DataBoundItem);
                            DataTable dt = DTO.PODInfo.ToDataTable();
                            dt.Rows.Add(info.ToDataRow(dt));
                            DataSet ds = new DataSet();
                            ds.Tables.Add(dt);
                            MainForm main = GetMainForm();
                            if (main != null)
                                main.PrintDataSet(ds, _strType);
                        }
                        break;
                }

                if (sErr == "")
                    ThrowMsg("Command: " + _processStatus);
            }
            catch (Exception ex)
            {
                ThrowMsg(ex.Message + Environment.NewLine + ex.Source);
            }
        }

        #region .::| Override Functions |::.
        protected override ModuleParent.ErrorStatus validateForm(ref string sErr)
        {
            ErrorStatus result = ErrorStatus.SUCCESS;
            sErr = "";
            if (txtUSER_ID.Text.Trim() == "")
            {
                sErr = "Could not save blank, please check!";
                errProvider.SetError(txtUSER_ID, sErr);
                strAction = _processStatus;
                sErr += "\n";
            }
            else errProvider.SetError(txtUSER_ID, "");

            if (sErr != "") result = ErrorStatus.ERROR;
            return result;
        }

        protected override bool checkExists()
        {
            return new BUS.PODControl().IsExist(txtUSER_ID.Text);
        }
        protected override string addRecord(bool isDraft = false)
        {
            string sErr = "";

            BUS.PODControl ctr = new BUS.PODControl();
            DTO.PODInfo info = GetData();
            ctr.Add(info, ref sErr);


            return sErr;
        }
        protected override string updateRecord(bool isDraft = false)
        {
            string sErr = "";

            BUS.PODControl ctr = new BUS.PODControl();
            DTO.PODInfo info = GetData();
            sErr = ctr.Update(info);

            return sErr;

        }
        protected override string delRecord()
        {
            string sErr = "";
            BUS.PODControl ctr = new BUS.PODControl();
            sErr = ctr.Delete(txtUSER_ID.Text);
            return sErr;
        }

        protected override void refreshForm(string val)
        {
            txtUSER_ID.Text = val;
            txtUSER_NAME.Text = val;
            mcbROLE_ID.Value = val;
            txtPASS.Text = Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(val)));
            txtLANGUAGE.Text = val;
            txtDB_DEFAULT.Text = val;
        }
        protected override void enableForm(bool val)
        {
            txtUSER_ID.Enabled = val;
            txtUSER_NAME.Enabled = val;
            mcbROLE_ID.Enabled = val;
            txtLANGUAGE.Enabled = val;
            txtDB_DEFAULT.Enabled = val;
            btnReset.Enabled = val;
        }
        protected override void reloadList()
        {
            GetMainForm().LoadDataTable(_strType);
            bsPOD.DataSource = GetMainForm().GetTable(_strType);
        }
        protected override void loadRecord(object o)
        {
            if (o is DataRowView)
            {
                DTO.PODInfo inf = new DTO.PODInfo((DataRowView)o);
                SetData(inf);
            }
        }

        #endregion



        private DTO.PODInfo GetData()
        {
            return new DTO.PODInfo(txtUSER_ID.Text
                , _strType
                , ""
                , txtUSER_NAME.Text
                , txtDB_DEFAULT.Text
                , txtLANGUAGE.Text
                , mcbROLE_ID.Value
                , txtPASS.Text
                , "");

        }


        private void SetData(DTO.PODInfo info)
        {
            txtUSER_ID.Text = info.USER_ID;
            txtUSER_NAME.Text = info.USER_NAME;
            mcbROLE_ID.Value = info.ROLE_ID;
            txtPASS.Text = info.PASS;
            txtLANGUAGE.Text = info.LANGUAGE;
            txtDB_DEFAULT.Text = info.DB_DEFAULT;
        }


        #endregion

        private void POD_Load(object sender, EventArgs e)
        {
            BUS.VENDORControl ctrVD = new BUS.VENDORControl();
            DataTable dtDepartment = ctrVD.GetAll_VENDOR(ref sErr);

            // test
            DataView dvCombo = new DataView(dtDepartment);
            bsCombo.DataSource = dvCombo;
            test1.ControlSize = test1.Width;
            //With large lists the data loads much faster if you specify the column widths
            //Up to 10 columns are allowed in this design
            //test1.ColumnWidths = new int[] { 36, 69, 300 };
            //Column visibility to hide set width to 0 and visible to false
           // test1.ColumnVisible = new bool[] { true, true, true };
            //Initialise return array
           // test1.RowData = new string[] { "", "", "" };
            //Can have up to three filters -1 = disable
            test1.FilterColumn = new int[] { 1, -1, -1 };
            //Initialise filters
            test1.FilterValue = new string[] { "<> ''", "", "" };
            //Search method find first or filter
            test1.Filter = false;
            test1.KeyPressChk = false;
            test1.Binding = bsCombo;

            
            enableForm(false);
            refreshForm("");
            LoadMultiCombo();


            if (idAllowEditLanguage >= GetMainForm().Permission.Length || GetMainForm().Permission[idAllowEditLanguage] == 'Y')
                AllowEditLanguage();
        }

        private void LoadMultiCombo()
        {

            if (!GetMainForm().IsContainsTables("POG"))
                GetMainForm().LoadDataTable("POG");
            mcbROLE_ID.Binding = GetMainForm().GetDuplicateTable("POG");
            GridLayout alayout = new GridLayout(MainForm.ServerPath + "Resources\\Layout\\", String.Format("{0}Documents\\Layout\\{1}\\", MainForm.ServerPath, GetMainForm().PODInfo.USER_ID), "POG");
            GetMainForm().InitMultiComboBox(mcbROLE_ID, alayout, DTO.POGInfo.Field.ROLE_NAME.ToString(), DTO.POGInfo.Field.ROLE_ID.ToString());
        }

        private void lklROLE_ID_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (_processStatus == "A" || _processStatus == "O" || _processStatus == "C")
            {
                Forms.frmMsg frm = new Forms.frmMsg();
                frm.FormClosed += delegate(object form, FormClosedEventArgs args)
                {
                    if (((Gizmox.WebGUI.Forms.Form)form).DialogResult == DialogResult.OK)
                    {
                        GetMainForm().SelectCategory("POG", "");
                    }

                };
                frm.ShowMsg(string.Format(clsConfigurarion.GetErrMsg("E0012", language), "Role Operator"));

            }
            else GetMainForm().SelectCategory("POG", "");
        }



        private void btnReset_Click(object sender, EventArgs e)
        {
            txtPASS.Text = Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes("")));
            btnReset.Enabled = false;
        }

        public string Connecstr { get; set; }

        private void txtUSER_ID_LostFocus(object sender, EventArgs e)
        {
            txtUSER_ID.Text = txtUSER_ID.Text.ToUpper();
            txtUSER_NAME.Focus();
        }



    }
}
